package com.gupaoedu.factory.simplefactory;

import com.gupaoedu.factory.ICourse;

/**
 * com.gupaoedu.factory.simplefactory
 * linwenjie
 * 2019-05-29
 */
public class CourseFactory {

/*    public ICourse create(String name){
        if("Java".equals(name)){
            return new JavaCourse();
        }else{
            return null;
        }
    }*/

/*    public ICourse create(String className) {
        try {
            if(!(null==className || "".equals(className))){
                return (ICourse) Class.forName(className).newInstance();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }*/

    public ICourse create(Class className) {
        try {
            if (!(null == className)) {
                return (ICourse) className.newInstance();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}


